package com.bjqh.edu.UI.Utils;

import android.content.Context;
import android.widget.Toast;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;

/**
 * Created by Administrator on 2017/12/5 0005.
 */

public class ComnUtils {

    private static ComnUtils comnUtils;
    private Context context;

    private ComnUtils(Context context) {
        this.context = context;
    }

    public static ComnUtils getInstanceOfComnUtils(Context context) {
        if (null == comnUtils) {
            comnUtils = new ComnUtils(context);
        }
        return comnUtils;
    }

    public void Tip(String msg) {
        Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
    }


    // 生成百家云的进入地址
    public  String getUrl(Map<String, Object> pram, String host) {
        String pr = null;
        for (String key : pram.keySet()) {
            // pram.get(key)
            if (null == pr) {
                pr = key + "=" + pram.get(key);

            } else {

                pr += "&" + key + "=" + pram.get(key);
            }

        }
        try {
            URL u = new URL(pr);
            return host + "?" + u.toString();
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return host + "?" + pr;

    }
}
